import React, { useEffect, useState } from 'react'
import { Button } from 'antd'
import {
  MoonOutlined,
  SunOutlined
} from '@ant-design/icons';
function Huanf() {
    const [theme,setTheme]=useState(()=>{
        return localStorage.getItem('theme')||'day'
    })
    useEffect(()=>{
        document.documentElement.setAttribute('data-theme',theme)
        localStorage.setItem('theme',theme)
    })
  return (
    <div>
      <Button onClick={()=>setTheme(theme==='day'?'Night':'day')}>{theme==='day'?<MoonOutlined />:<SunOutlined />}</Button>
    </div>
  )
}

export default Huanf
